package com.hairline.hairlinemarket.controller;

import com.hairline.hairlinemarket.bean.MarketCoupon;
import com.hairline.hairlinemarket.bean.MarketUser;
import com.hairline.hairlinemarket.bean.common.BaseRespVo;
import com.hairline.hairlinemarket.service.CouponService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author:杨小凯
 * Date:2023-04-22 16:49
 * Description:<描述>
 */
@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private CouponService couponService;

    @RequestMapping("/selectlist")
    public BaseRespVo selectList(Integer cartId, Integer grouponRulesId) {
        // 获取信息
        Subject subject = SecurityUtils.getSubject();
        MarketUser principal = (MarketUser) subject.getPrincipal();
        // 拿到了个人id信息
        Integer userId = principal.getId();
        // TODO 返回用户优惠券
        List<MarketCoupon> couponList =couponService.selectCoupon(userId);

        return BaseRespVo.ok(couponList);
    }
}
